<div class="preferences-section">
  <div class="section-header">
    <h3 class="section-title">
      <i class="pi pi-save"></i>
      Metadata Persistence
    </h3>
  </div>

  <div class="settings-card">
    <div class="setting-item">
      <div class="setting-info">
        <div class="setting-label-row">
          <label class="setting-label">Write to File</label>
          <p-toggleswitch
            [ngModel]="metadataPersistence.saveToOriginalFile"
            (onChange)="onPersistenceToggle('saveToOriginalFile')">
          </p-toggleswitch>
        </div>
        <p class="setting-description">
          <i class="pi pi-exclamation-triangle"></i>
          Writes metadata directly into the original file. A backup of the metadata and/or cover is created only if enabled below. Proceed with caution, restoration may fail if the file is moved or renamed.
        </p>
      </div>
    </div>

    <div class="setting-item">
      <div class="setting-info">
        <div class="setting-label-row">
          <label class="setting-label">Backup Metadata</label>
          <p-toggleswitch
            [ngModel]="metadataPersistence.backupMetadata"
            (onChange)="onPersistenceToggle('backupMetadata')"
            [disabled]="!metadataPersistence.saveToOriginalFile">
          </p-toggleswitch>
        </div>
        <p class="setting-description">
          <i class="pi pi-info-circle"></i>
          Save a JSON copy of the current metadata before writing new data to the file.
        </p>
      </div>
    </div>

    <div class="setting-item">
      <div class="setting-info">
        <div class="setting-label-row">
          <label class="setting-label">Backup Cover</label>
          <p-toggleswitch
            [ngModel]="metadataPersistence.backupCover"
            (onChange)="onPersistenceToggle('backupCover')"
            [disabled]="!metadataPersistence.saveToOriginalFile">
          </p-toggleswitch>
        </div>
        <p class="setting-description">
          <i class="pi pi-info-circle"></i>
          Save a copy of the existing embedded cover image before it is replaced.
        </p>
      </div>
    </div>
  </div>
</div>
